home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / p_misc / 7p203upp.exe / V203SRC.LZH / 7PLUS.H < prev    next >
C/C++ Source or Header  |  1992-07-12  |  8KB  |  285 lines

  1. /*---------*\
  2. >  7plus.h  <
  3. \*---------*/
  4.  
  5. /* Uncomment next line, if compiling on AMIGA! */
  6. /* #define _AMIGA_ */
  7.  
  8. #define YES "yes"
  9. #define ALWAYS "always"
  10. #define NO  "no"
  11. #define EOS '\0'
  12.  
  13. /* Some compilers are very strict abt the type of NULL-pointers */
  14. #define NULLFP ((FILE *) 0)
  15. #define NULLCP ((char *) 0)
  16.  
  17. /** these includes should work anywhere **/
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include <sys/stat.h>
  21. #include <time.h>
  22. #include <ctype.h>
  23. #include <errno.h>
  24. #include <limits.h>
  25.  
  26. #ifdef __M_XENIX__
  27.  #include <malloc.h>
  28.  #define SEEK_CUR 1
  29.  #define SEEK_END 2
  30.  #define SEEK_SET 0
  31.  typedef unsigned size_t;
  32. #else
  33.  #include <stdlib.h>
  34. #endif
  35. #ifdef SYSV
  36.  #include <unistd.h> /* not sure, if this one is really necessary */
  37. #endif
  38.  
  39. /* flags for fopen() */
  40. #define OPEN_READ_TEXT "r"
  41. #define OPEN_WRITE_TEXT "w"
  42. #define OPEN_APPEND_TEXT "a"
  43. #define OPEN_RANDOM_TEXT "r+"
  44. #ifdef __unix__
  45.  #define OPEN_READ_BINARY "r"
  46.  #define OPEN_WRITE_BINARY "w"
  47.  #define OPEN_APPEND_BINARY "a"
  48.  #define OPEN_RANDOM_BINARY "r+"
  49. #else
  50.  #define OPEN_READ_BINARY "rb"
  51.  #define OPEN_WRITE_BINARY "wb"
  52.  #define OPEN_APPEND_BINARY "ab"
  53.  #define OPEN_RANDOM_BINARY "r+b"
  54. #endif
  55.  
  56. /* Microsoft's Quick C has some different makros and function names **/
  57. #ifdef _QC
  58.  #define __MSDOS__
  59.  #define MAXDRIVE _MAX_DRIVE
  60.  #define MAXDIR   _MAX_DIR
  61.  #define MAXFILE  _MAX_FNAME
  62.  #define MAXEXT   _MAX_EXT
  63.  #define MAXPATH  _MAX_PATH
  64.  #define fnsplit  _splitpath
  65. #endif
  66.  
  67. #ifdef __MSDOS__
  68.  #ifdef __TURBOC__
  69.   #include <dir.h>
  70.   #include <io.h>
  71.  #endif
  72.  #include <conio.h>
  73.  #define PATHSEP "\\"
  74.  #define PATHCHAR '\\'
  75.  #define INDICATE 0xdb
  76.  #define TWO_CHAR_SEP
  77.  #define MAXFNAME MAXFILE+MAXEXT-1
  78.  #define _CHSIZE_OK
  79. #endif
  80.  
  81. #ifdef _AMIGA_
  82.  #undef  YES
  83.  #define YES ""
  84.  #undef  NO
  85.  #define NO ""
  86.  #undef ALWAYS
  87.  #define ALWAYS ""
  88.  #define SEEK_SET 0
  89.  #define SEEK_CUR 1
  90.  #define SEEK_END 2
  91.  #define MAXPATH  300
  92.  #define MAXDRIVE 5
  93.  #define MAXDIR   220
  94.  #define MAXFILE  31
  95.  #define MAXEXT   31
  96.  #define PATHSEP  "/"
  97.  #define PATHCHAR '/'
  98.  #define INDICATE '*'
  99.  #define MAXFNAME MAXFILE
  100.  #define _FNSPLIT
  101.  #define _ICMP
  102.  #define getch getchar
  103. #endif
  104.  
  105. #ifdef __TOS__
  106.  #define MAXPATH   119
  107.  #define MAXDRIVE  3
  108.  #define MAXDIR    102
  109.  #define MAXFILE   9
  110.  #define MAXEXT    5
  111.  #define PATHSEP "\\"
  112.  #define PATHCHAR '\\'
  113.  #define TWO_CHAR_SEP
  114.  #define INDICATE 0xdb
  115.  #define MAXFNAME MAXFILE+MAXEXT-1
  116.  #define _FNSPLIT
  117.  #include <ext.h>
  118.  /* quick & dirty, swaps upper and lower word                      */
  119.  unsigned long swapl(unsigned long l)0x4840; /* opcode for SWAP D0 */
  120.  /* needed for timestamp-functions    (Odo,DL1XAO)                 */
  121. #endif
  122.  
  123.   
  124. #ifdef __unix__
  125. /* assumed limits (hope reasonable !!! DF6NL) */
  126.  #define ON 0
  127.  #define OFF 1
  128.  #define MAXPATH 256
  129.  #define MAXDRIVE 16
  130.  #define MAXDIR 256
  131.  #define MAXFILE 32
  132.  #define MAXEXT 32
  133.  #define PATHSEP "/"
  134.  #define PATHCHAR '/'
  135.  #define INDICATE '*'
  136.  #define MAXFNAME MAXFILE
  137.  #define _ICMP
  138.  #define _FNSPLIT
  139.  #define getch my_getch
  140.  #ifdef __i386__
  141.   #ifndef SYSV
  142.    #define SYSV
  143.   #endif
  144.  #endif
  145.  
  146.  #ifdef SYSV
  147.   #include <termio.h>
  148.   struct termio sg[2];
  149.  #else
  150.   #include <sgtty.h>
  151.   struct sgttyb sg[2];
  152.  #endif
  153. #endif /* __unix__ */
  154.  
  155. #define MAXFPATH MAXDRIVE+MAXDIR-1
  156.  
  157. /** shorthands for unsigned types **/
  158. typedef unsigned char byte;  /* 8bit unsigned char       */
  159. #ifdef __unix__
  160.  #include <sys/types.h>
  161.  #ifdef __vax__
  162.    typedef u_long ulong;
  163.  #endif
  164.  #ifdef __M_XENIX__
  165.    typedef unsigned long ulong;
  166.  #endif
  167. #else
  168.  typedef unsigned int  uint;  /* 16 or 32bit unsigned int */
  169.  typedef unsigned long ulong; /* 32bit unsigned long      */
  170. #endif
  171.  
  172. struct  m_index {
  173.   char  filename[14];  /*12  chars +2*/
  174.   char  full_name[258];/*256 chars +2*/
  175.   ulong length;
  176.   ulong timestamp;
  177.   uint  splitsize;
  178.   ulong lines_ok[4080];
  179.   long  lines_left;
  180. };
  181.  
  182. /***************** function prototypes ******************/
  183.  
  184. /** 7plus.c **/
  185. int   go_at_it       (int argc, char **argv);
  186.  
  187. /** encode.c **/
  188. int   encode_file    (char *name, long blocksize, char *searchbin,
  189.                                                   int part, char *head_foot);
  190. int   read_tb        (char *name, char *go_top, char *go_bottom);
  191. int   top_bottom     (FILE *wfile, char *top_bot, char *orgname,
  192.                                                         int part, int parts);
  193. /** decode.c **/
  194. int   control_decode (char *name);
  195. int   decode_file    (char *name, int flag);
  196. void  decode_n_write (FILE *raus, char *p, int length);
  197. void  w_index_err    (struct m_index *index, int flag);
  198. int   make_new_err   (char *name);
  199. void  progress       (char *filename, int part, int of_parts, long errors,
  200.                                                  long rebuilt, char *status);
  201. /* correct.c */
  202. int   correct_meta   (char *name, int itsacor);
  203.  
  204. /** util.c **/
  205. char  *my_fgets      (char *string, register n, FILE *rein);
  206. int   my_putc        (int  outchar, FILE *out);
  207. void  crc_n_lnum     (uint *crc, int *linenumber, char *line);
  208. void  crc2           (uint *crc, char *line);
  209. void  add_crc2       (char *line);
  210. int   mcrc           (char *line, int flag);
  211. int   read_index     (FILE *ifile, struct m_index *index);
  212. int   write_index    (FILE *ifile, struct m_index *index, int flag);
  213. ulong read_ulong     (FILE *in);
  214. uint  read_uint      (FILE *in);
  215. void  write_ulong    (FILE *out, ulong val);
  216. void  write_uint     (FILE *out, uint val);
  217. int   crc_file       (char *file, char *s1, char *s2, int flag);
  218. int   copy_file      (char *to, char *from, ulong timestamp);
  219. void  replace        (char *old, char *new, ulong timestamp);
  220. void  kill_em        (char *name, char *inpath, char *one, char *two,
  221.                                         char *three, char *four, char *five);
  222. void  kill_dest      (FILE *in, FILE *out, char *name);
  223. int   test_exist     (char *filename);
  224. int   test_file      (FILE *in, char *destnam, int flag, int namsize);
  225. void  init_decodetab (void);
  226. void  init_codetab   (void);
  227. void  init_crctab    (void);
  228. void  build_DOS_name (char *name);
  229. #if defined (__MSDOS__) || (__TOS__)
  230.  ulong get_filetime   (FILE *_file);
  231.  void  set_filetime   (FILE *_file, ulong ftimestamp);
  232. #else
  233.  #ifndef _HAVE_GMTIME
  234.   struct tm *__offtime (const time_t *t, long int offset);
  235.   struct tm *gmtime    (const time_t *t);
  236.  #endif
  237.  #ifndef _HAVE_MKTIME
  238.   time_t    mktime     (register struct tm *tp);
  239.  #endif
  240.  ulong get_filetime (char *filename);
  241.  void  set_filetime (char *filename, ulong ftimestamp);
  242. #endif
  243. uint  get_hex        (char *hex);
  244. #ifdef _FNSPLIT
  245.   void  fnsplit      (char *pth, char *dr, char *pa, char *fn, char *ft);
  246. #endif
  247. #ifdef _ICMP
  248.   char  *strupr      (char *string);
  249.   char  *strlwr      (char *string);
  250.   char  *strcnvt     (char *string, int flag);
  251.   int   stricmp      (const char *s1, const char *s2);
  252.   int   strnicmp     (const char *s1, const char *s2, size_t n);
  253. #endif
  254.  
  255. /** rebuild.c **/
  256. int   rebuild        (char *line, int flag);
  257.  
  258. /** extract.c **/
  259. int   extract_files  (char *name, char *search);
  260.  
  261. /** join.c **/
  262. int   join_control   (char *file1, char *file2);
  263. int   join_err       (char *file1, char *file2);
  264.  
  265. /** unix.c **/
  266. #ifdef __unix__
  267.  int       my_getch   (void);
  268.  
  269.  #ifdef __i386__
  270.   #ifndef _HAVE_STRSTR
  271.    char     *strstr    (const char *s1, const char *s2);
  272.   #endif
  273.   int      rename     (const char *s1, const char *s2);
  274.  #endif
  275.  
  276.  #ifdef __vax__
  277.   #ifdef __STDC__
  278.    extern char *strdup (const char *);
  279.   #else
  280.    extern char *strdup ();
  281.   #endif
  282.  #endif
  283.  
  284. #endif
  285.